﻿using System;

namespace UniversalApproach.Converters
{
    public static class StringConvert
    {
        public static byte[] Base64StrToBytes(string base64Str)
        {
            if (string.IsNullOrWhiteSpace(base64Str))
                throw new ArgumentNullException("参数不能为空！");

            var tmpStr = base64Str.Replace("data:image/png;base64,", "")
                                        .Replace("data:image/jgp;base64,", "")
                                        .Replace("data:image/jpg;base64,", "")
                                        .Replace("data:image/jpeg;base64,", "");//将base64头部信息替换

            return Convert.FromBase64String(tmpStr);
        }
    }
}